<?php 
    if($_FILES['async-upload']['name']!='')
    {
        $uploadDir=dirname(__FILE__).'/../product';
        $file=$_FILES['async-upload'];
        $extension = strtolower(substr(strrchr($file['name'], '.'), 1));
        $fileName=rtrim(strstr($file['name'], $extension, true),'.');
        $strRand=mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y'));
        $fileNameUpload=$fileName.'_'.$strRand.'.'.$extension;
        if(move_uploaded_file($file['tmp_name'], $uploadDir.'/'.$fileNameUpload))
        {
            echo '<img src="/uploads/product/'.$fileNameUpload.'" width="40" height="40" />';
        }
        else
        {
            echo 'error';
        }
    }
    else
    {
        echo 'File không tồn tại!';   
    }
?>